package com.liuyz.thread_;

// 继承Thread类
public class Thread_ {

    public static void main(String[] args) throws InterruptedException {
        // Thread.sleep(3000);

        Cat cat = new Cat();
        cat.start();
        // cat.run();

        for (int i = 0; i < 50; i++) {
            System.out.println("主线程执行次数：" + (i + 1) + " 线程名：" + Thread.currentThread().getName());
            Thread.sleep(1000);
        }
    }
}

class Cat extends Thread {

    int nums = 0;

    @Override
    public void run() {
        while (true) {
            System.out.println("一只猫_" + (++nums) + " 线程名：" + Thread.currentThread().getName());
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (nums == 80) {
                break;
            }
        }
    }
}